<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<%@include file="../common/selfCss.jsp"%>
<script type="text/javascript">

	var grid_ae = null;
	var dialog_ae = null;
	$(function(){
		grid_ae = $("#pictorial_grid").ligerGrid({
                columns: [
                { display: '画报ID', name: 'pictorial',isSort : false, width: 100,
                	render: function (record, rowindex, value, column){
						var html = '<a onclick="detail(\''+ value + '\',\''+ record.pictorialObj.title + '\')" href="javascript:;">'+value+'</a>';
                		return html;
					}	
                },
                { display: '画报名称', name: 'pictorialObj', isSort : false, width: 200,
                	render: function (record, rowindex, value, column){
                		return value.title;
                	}
                },
                { display: '画报描述', name: 'pictorialObj',isSort : false, width: 500,
                	render: function (record, rowindex, value, column){
                		return value.description;
                	}	
                },
                { display: '画报作者', name: 'pictorialObj',isSort : false, width: 100,
                	render: function (record, rowindex, value, column){
                		return value.member;
                	}
                },
                { display: '状态', name: 'pictorialObj',isSort : false, width: 50,
                	render: function (record, rowindex, value, column){
                		if(value.display=='01'){
                			return "显示"
                		}
                		if(value.display=='02'){
                			return "屏蔽";
                		}
                	}	
                },
                {
                	display: '<a href="javascript:;" onclick="addPictorial()">新增画报</a>', 
                	name: 'pictorial',
                	isAllowHide: false, 
                	isSort : false,
					render: function (record, rowindex, value, column){
					//this     这里指向grid
					//record   行数据
					//rowindex 行索引
					//value    当前的值，对应record[column.name]
					//column   列信息
						var html = '';
							//html+='<a onclick="sortPic()" href="javascript:;">排序</a>&nbsp;<a onclick="removeFromTopic(\''+ value + '\')" href="javascript:;">删除</a>'; 
							//html+= '<a onclick="pictorialManage(\''+ value + '\',\''+ record.name + '\')" href="javascript:;">画报管理</a>&nbsp;'
							html+='&nbsp;<a onclick="edit(\''+ value + '\',\''+ record.pictorialTopic + '\')" href="javascript:;">编辑</a>';
							//html+='&nbsp;<a onclick="deletePictorial(\''+ value + '\')" href="javascript:;"></a>';
							html+='&nbsp;<a onclick="move(\''+ value + '\',\'up\')" href="javascript:;">上移</a>';
							html+='&nbsp;<a onclick="move(\''+ value + '\',\'down\')" href="javascript:;">下移</a>';
							html+='&nbsp;<a onclick="move(\''+ value + '\',\'top\')" href="javascript:;">置顶</a>';
						return html; 
					}
                }
                ], 
                pageSize:10,
                root :'list',
                record:'totalRecord',
                url: "/misc/tag/pictorialGrid.htm?id=${id}", 
                enabledEdit: true,
                width: '99%',height:'99%',
                fixedCellHeight : false
            });

	});
	//移出主题
	function deletePictorial(pictorial){
		$.ligerDialog.confirm('你确定移除该画报吗？', 
				function (yes){
					if(yes){
						$.post("/misc/album/deletepictorial.htm",{
							pictorialId:pictorial,
							topicId:'${id}'
						},function(data){
							if(data == 'success'){
								grid_ae.loadData();
								$.ligerDialog.success("移除成功");
							}else{
								$.ligerDialog.warn("由于系统抽经，刚才的操作不成功，请稍候再试");
							}
						});
					}
				});
	}
	
	
	function move(pictorialId,moveType){
		$.post("/misc/topic/movepictorial.htm",{topicId:"${id}",pictorialId:pictorialId,moveType:moveType},function(data){
			if(data=="success"){
				grid_ae.loadData();
			}
		})
	}
	
	//排序
	function sortPic(){
		var data = grid_ae.getSelected();
		$.post("/misc/tag/sortPic.htm",{
			pictorial : data.identifier,
			pictorialTopic : '${id}',
			sort: data.sort
		},function(data){
			if(data == 'success'){
				grid_ae.loadData();
				$.ligerDialog.success("排序成功");
			}else{
				$.ligerDialog.warn("由于系统抽经，刚才的操作不成功，请稍候再试");
			}
		});
	}
	//搜索
	function search(){
		var nickname = $("#nickname").val();
		var title = $("#title").val();
		grid_ae.options.parms = [{name:'nickname',value:nickname},{name:'title', value : title}];
		grid_ae.loadData();
	}
	
	function detail(id,title){
		dialog_ae = $.ligerDialog.open({ height: 500,width:950, url: "/misc/album/albumdoing.htm?pictorialId="+id, showMax:true,showMin:true,isResize:true,isDrag:false,title:title});
	}
	
	//添加专辑
	function addPictorial(){
		dialog_ae = $.ligerDialog.open({ height: 500,width:900, url: "/misc/album/addalbum.htm?topicId=${id}", showMax:true,showMin:true,isResize:true,isDrag:false,title:'新增画报'});
	
	}
	
	function edit(id,topicId){
		dialog_ae = $.ligerDialog.open({ height: 500,width:900, url: "/misc/album/editalbum.htm?id="+id+"&topicId="+topicId, showMax:true,showMin:true,isResize:true,isDrag:false,title:'编辑专辑'});
	}
</script>

<div id="pictorial_grid" style="margin:0; padding:0"></div>

